<?php
class Core_Data_Mappers_Userexpertises extends Core_Data_Mappers_Abstract {
	protected $_modelclass = 'Core_Data_Models_Userexpertises';
	protected $_map = array("Userid"=>"userid","Expertisesid"=>"expertisesid");
	protected $_businessclass = "Core_Business_Userexpertises";
	
	public function find($object){
		$data = $this->getDbTable()->fetchAll(array("userid = ?"=>$object->Userid,"expertisesid = ?"=>$object->Expertisesid));
		if(isset($data) && is_array($data) && count($data)>0) 
			return $this->map(current($data));
		else
			null;
	}
	
	public function exists($object) {
		if($this->find($object))
			return true;
		else
			return false;
	}
	public function add($object){
		if(!$this->exists($object)) {
			$data = $this->reversemap($object);
			$this->getDbTable()->insert($data);
		}
	}
	
	public function edit($object) {}
	public function delete($object) {
		if(!$this->exists($object)) {
			$this->getDbTable()->delete(array("userid = ?"=>$object->Userid,"expertisesid = ?"=>$object->Expertisesid));
		}		
	}
	public function deleteall($object) {
	if(!$this->exists($object)) {
			$this->getDbTable()->delete(array("userid = ?"=>$object->Userid));
		}
	}
}